constraint solver: Fix repeat suggestions
authorMatthias Clasen <mclasen@redhat.com>
Fri, 28 Jun 2019 16:59:39 +0000 (16:59 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Sun, 30 Jun 2019 23:10:11 +0000 (00:10 +0100)
We were not storing the previous value, causing
the first two suggestions to work, but not later
ones.

Fixes the test added in the previous commit.

gtk/gtkconstraintsolver.c

index 3c3a5289f35b570d78daa1a5e35427f0390d1c9b..8c0fe08669ec72746111b485eac304f8e94ab72b 100644 (file)
@@ -1971,6 +1971,7 @@ gtk_constraint_solver_suggest_value (GtkConstraintSolver *self,
                                      double value)
 {
   EditInfo *ei = g_hash_table_lookup (self->edit_var_map, variable);
+  double delta;
   if (ei == NULL)
     {
       g_critical ("Suggesting value '%g' but variable %p is not editable",
@@ -1986,9 +1987,10 @@ gtk_constraint_solver_suggest_value (GtkConstraintSolver *self,
       return;
     }
 
-  ei->prev_constant = value - ei->prev_constant;
+  delta = value - ei->prev_constant;
+  ei->prev_constant = value;
 
-  gtk_constraint_solver_delta_edit_constant (self, ei->prev_constant, ei->eplus, ei->eminus);
+  gtk_constraint_solver_delta_edit_constant (self, delta, ei->eplus, ei->eminus);
 }
 
 /*< private >